package com.love.marriage.cloud.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.love.marriage.cloud.service.BaiduyunService;
import com.love.marriage.cloud.service.TencentDtService;
import com.love.marriage.common.vo.Result;
import com.love.marriage.common.vo.ResultBoolean;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * description:  用户登录历史表restApi
 * author:       mybatisPlus
 * createDate:   2024-10-12 11:25:06
 * version:      1.0.0
 */
@ApiSort(100)
@Tag(name = "百度云相关接口", description = "百度云相关接口")
@RestController
@RequiredArgsConstructor
@RequestMapping("/baiduyun")
public class BaiduyunController {

    private final BaiduyunService baiduyunService;

    private final TencentDtService tencentDtService;

    @ApiOperationSupport(order = 10, author = "alex")
    @Operation(summary = "通过ip获取地址", description = "通过ip获取地址")
    @ApiResponse(responseCode = "200", description = "Success",
            content = @Content(mediaType = "application/json",
                    schema = @Schema(implementation = ResultBoolean.class
                    )))
    @GetMapping(value = "/ip2address")
    @Parameters({
            @Parameter(name = "ip", description = "地址", required = false)
    })
    @Tag(name = "公共", description = "公共接口")
    public Result<Map<String, Object>> ip2address(HttpServletRequest request,
                                                  @RequestParam(value = "ip", required = false) String ip) throws Exception {
        return Result.success(tencentDtService.ip2address(request, ip));
    }
}
